﻿module CssExpanderTests

open NUnit.Framework
open CssTypes
open CssParser
open CssExpander


[<TestFixture>]
type testCssExpand() =


    [<Test>]
    member this.testPaddingShorthand() =
        let ss = toStyleSpec [Declaration("padding", [Measure(2.0M, "px");Measure(3.0M, "px")], false)]
        Assert.AreEqual(4, ss.map.Count)
        Assert.AreEqual(Measure(2.0M, "px"), ss.map.["padding-top"])
        Assert.AreEqual(Measure(3.0M, "px"), ss.map.["padding-right"])
        ()

    [<Test>]
    member this.testFontShorthand() =
        let ss = toStyleSpec [Declaration("font", [IdentifierTerm("bold");IdentifierTerm("italic");IdentifierTerm("large");IdentifierTerm("sans-serif")], false)]
        Assert.AreEqual(6, ss.map.Count)
        Assert.AreEqual(IdentifierTerm("bold"), ss.map.["font-weight"])
        Assert.AreEqual(IdentifierTerm("italic"), ss.map.["font-style"])
        Assert.AreEqual(IdentifierTerm("normal"), ss.map.["font-variant"])
        Assert.AreEqual(IdentifierTerm("large"), ss.map.["font-size"])
        Assert.AreEqual(IdentifierTerm("normal"), ss.map.["line-height"])
        Assert.AreEqual(IdentifierTerm("sans-serif"), ss.map.["font-family"])
        ()

    [<Test>]
    member this.testFontShorthand2() =
        let ss = toStyleSpec [Declaration("font", [Slash(Measure(12.0M, "px"), Number(1.2M));TermList([StringTerm("Times new roman");IdentifierTerm("serif")])], false)]
        Assert.AreEqual(6, ss.map.Count)
        Assert.AreEqual(IdentifierTerm("normal"), ss.map.["font-weight"])
        Assert.AreEqual(IdentifierTerm("normal"), ss.map.["font-style"])
        Assert.AreEqual(IdentifierTerm("normal"), ss.map.["font-variant"])
        Assert.AreEqual(Measure(12.0M, "px"), ss.map.["font-size"])
        Assert.AreEqual(Number(1.2M), ss.map.["line-height"])
        Assert.AreEqual(TermList([StringTerm("Times new roman");IdentifierTerm("serif")]), ss.map.["font-family"])
        ()